from flask import Blueprint, request

from .insert_msg import InsertMsg


app_msg = Blueprint('app_msg',__name__)

@app_msg.route('/msg',methods=['POST'])
def msgs():
    info = request.form
    start_point = info.get('start_point')
    destination = info.get('destination')
    start_time = info.get('start_time')
    pick_up_point = info.get('pick_up_point')
    people_number = info.get('people_number')
    user_id = info.get('user_id')

    with InsertMsg()as IM:
        IM.insert_info(start_point,destination,start_time,
                                pick_up_point,people_number,user_id)

    return InsertMsg().return_message(start_point,destination,start_time,
                            pick_up_point,people_number)


